import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Layout from '@/views/layout/Layout'

export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/authredirect', component: () => import('@/views/login/authredirect'), hidden: true },
  { path: '/404', component: () => import('@/views/errorPage/404'), hidden: true },
  { path: '/401', component: () => import('@/views/errorPage/401'), hidden: true },

  {
    path: '',
    component: Layout,
    redirect: 'main',
    children: [{
      path: 'main',
      component: () => import('@/views/dashboard/index'),
      name: 'dashboard',
      meta: { title: '首页', icon: 'dashboard', noCache: true }
    }]
  }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  {
    path: '/employees',
    component: Layout,
    redirect: '/list',
    meta: { title: '员工管理', icon: 'article', roles: ['admin'] },
    children: [{
      path: 'list',
      component: () => import('@/views/employees/list'),
      name: 'employeesList',
      meta: { title: '员工一览', icon: 'list', roles: ['admin'] }
    },
    {
      path: 'edit',
      component: () => import('@/views/employees/edit'),
      name: 'employeesEdit',
      meta: { title: '编辑员工', icon: 'edit', roles: ['admin'] }
    }]
  },
  { path: '*', redirect: '/404', hidden: true }
]
